﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;

namespace derp.classes
{
    public class soundEngine
    {
        public soundEngine(string path)
        {
            mPath = path;
            mAudioEngine = new AudioEngine(mPath);
        }
        ~soundEngine() { }

        //methods
        public AudioEngine getEngine() {  return mAudioEngine;   }

        AudioEngine mAudioEngine;
        string mPath;
    }

    public class waveBank
    {
        public waveBank(string path, AudioEngine aE)
        {
            mPath = path;
            mWaveBank = new WaveBank(aE, mPath);
        }

        //methods
        public WaveBank getWaveBank() {  return mWaveBank;       }

        WaveBank mWaveBank;
        string mPath;
    }

    public class soundBank
    {
        public soundBank(string path, AudioEngine aE)
        {
            mPath = path;
            mSoundBank = new SoundBank(aE, mPath);
        }

        //getter
        public SoundBank getSoundBank()
        {
            return mSoundBank;
        }

        SoundBank mSoundBank;
        string mPath;
    }

    public class cue
    {
        public cue()
        {
            mSound = null;
        }
        public cue(string soundName, SoundBank sB)
        {
            mSound = sB.GetCue(soundName);
        }

        //setter
        public void setSound(string soundName, SoundBank sB)
        {
            mSound = sB.GetCue(soundName);
        }

        //getter
        public Cue getCue()
        {
            return mSound;
        }

        // methods
        public void playSound()
        {
            if (mSound != null)
            {
                mSound.Play(); //causing a break??
            }
        }

        public void pauseSound()
        {
            if (mSound != null && mSound.IsPlaying)
            {
                mSound.Pause();
            }
        }

        public void resumeSound()
        {
            if (mSound != null && mSound.IsPaused)
            {
                mSound.Resume();
            }
        }

        public void stopSound(AudioStopOptions en)
        {
            if (mSound != null && mSound.IsPlaying)
            {
                if (en == AudioStopOptions.Immediate)
                {
                    mSound.Stop(AudioStopOptions.Immediate);
                }
                else if (en == AudioStopOptions.AsAuthored)
                {
                    mSound.Stop(AudioStopOptions.AsAuthored);
                }
            }
        }

        public void changeVolume(float v)
        { //Using SetVariable in accordance with the XACT RPC & variabel creation
            // Quirky as hell, I know.
            mSound.SetVariable("Volume", v);
        }

        public void changePitch(float p)
        {
            mSound.SetVariable("DopplerPitchScalar", p);
        }

        Cue mSound;
        //SoundBank sBankRef;
    }

    /*
    // OLD STUFF
    public class Sound
    {
        public Sound() { }
        ~Sound() { }

        public SoundEffect mEffect;
        float volume; //from 0.0f to 1.0f
    }

    public class Sound2D : Sound
    {   //this sound has a position in the game, the distance between the player and 
        //this sound determined the volume at which it is played
        Vector2 position; 
        float distance;
    }

    public class Music
    {
        public Music() { }
        ~Music() { }

        public Song mLiedje;
        float volume;
    }
    */
}
